<?php
/**
 * @author 	 	 supfire@sohu.com
 * @copyright		 yctool.com
 * @version		 1.0
 * @name 		 home.action.php
 * @todo 		 站点信息程序处理
 * @final 		 2009-05-09
 */
!defined("IN_YCTOOL") && exit();
require_once(DIR_COMM . 'cuthtml.func.php');
require_once(DIR_COMM . 'sendmail.php');

$fromuid = 1001;
$username = '童心网管理员';
//获取POST/GET方法提交的变量
$operation      = isset($_GET['operation']) ? $_GET['operation'] : "";
$actionPost     = isset($_POST['actionPost']) ? $_POST['actionPost'] : '';
$type		= isset($_POST['type']) ? $_POST['type'] : '';
$title		= isset($_POST['title']) ? $_POST['title'] : '';
$detail		= isset($_POST['detail']) ? $_POST['detail'] : '';
$detail    = str_replace(" ", "&nbsp;", $detail);
$detail    = str_replace("\n", "<br />", $detail);
$detail    = str_replace("\\", "", $detail);

$message = '<br /><br /><br />标题:'.$title;

$message .= '<br /><br />内容:'.$detail;

if($actionPost == 'add')
{

    $rs = db::getAll('sns_user_basic','userid,email,username',
        ' active <> 0 order by userid desc');
    if (!$rs) 
    {
       $rs = array();  	
    }

    foreach($rs as $k => $arr)
    {
        $userid = $arr['userid'];
        $touid = $userid . ',';
        $email = $arr['email'];
        $msgid = 0;

        switch ($type)
        {
        case 0:
            db::insertRs(DB_TABLEPRE . 'msg_thread', 'touid, fromuid, isdel, sendok,
		title, message, addtime', "'$touid', $fromuid, 1, 1, '$title', '$detail', ". time());
            break; 
        case 1:
            msg::Msendemail($userid, $username, $email, $message, $msgid, 0, 0);
            break;  
        case 2:
            db::insertRs(DB_TABLEPRE . 'msg_thread', 'touid, fromuid, isdel, sendok,
                title, message, addtime', "'$touid', $fromuid, 1, 1, '$title', '$detail', ". time());

            msg::Msendemail($userid, $username, $email, $message, $msgid, 0, 0);
            break;  
        default:;
        }
    }
    func::showMsg('修改成功 , 返回刷新可见结果', '../');
}

?>
